package cease.command.butter;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.Option;

import cease.butter.ButterExecutor;
import cease.command.HasOptionCommand;
import cease.console.PrintHelper;
import cease.urs.Session;
import cease.vo.Butter;

/**
 * @author dhf
 */
public class UnmuteButterCommand extends HasOptionCommand {
    @Option(name = "-i", usage = "butter id", metaVar = "required", required = true)
    private String butterId;

    private void reset() {
        butterId = null;
    }

    public String getCmdDesc() {
        return "unmute a butter";
    }

    public void run(Session session, String[] args) throws Exception {
        try {
            parser.parseArgument(args);
            Butter butter = ButterExecutor.getInstance().unmute(session,
                    butterId);
            PrintHelper.printButter(butter);
        } catch (CmdLineException e) {
            parser.printUsage(System.out);
        } finally {
            reset();
        }
    }

}
